﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HalconDotNet;

namespace Kimd.Vision
{
    [Serializable]
    public class TextNB : ShapeNB
    {
        public string Text;
        public PointF StartPoint;
        public string FontName;
        public float FontSize;
        public float Angle;

        public TextNB()
            : base()
        {
            FontSize = 60;
            Angle = 0;
        }

        public override void Draw(HWindow window, Graphics g, Func<PointF, PointF> pixel2Window, Func<float, float> lenConvert, bool disableEdit)
        {
            window.SetColor(PaintColor);
            window.SetLineWidth(LineWidth);
            int size = Math.Min((int)(1 / lenConvert(FontSize)), 20);
            FontName = string.Format("-Courier New-{0}-*-*-*-*-1-", size);
            window.SetFont(FontName);
            window.SetTposition((int)StartPoint.Y, (int)StartPoint.X);
            window.WriteString(Text);
        }
    }
}
